package com.whfc.ms.api.mach.controller.gscx;

import com.whfc.common.result.ListData;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.common.util.RequestAttr;
import com.whfc.common.util.SessionAttr;
import com.whfc.fuum.dto.AppCorpDTO;
import com.whfc.fuum.entity.SysUser;
import com.whfc.mach.dto.AppMachTypeDTO;
import com.whfc.ms.api.mach.service.MsMachOptionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author sun_guodong
 * @date 2020-11-30
 */
@RestController
@RequestMapping("/ms/api/gscx/mach/option")
public class MsGscxMachOptionController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private MsMachOptionService msMachOptionService;

    @GetMapping("/corpList")
    public Result corpList(@SessionAttribute(SessionAttr.MS_USER) SysUser user,
                           @RequestAttribute(RequestAttr.DEPT_ID) Integer deptId) {
        logger.info("获取设备的持有单位列表,loginer:{},deptId:{}", user.getUsername(), deptId);
        ListData<AppCorpDTO> listData = msMachOptionService.corpList(deptId);
        return ResultUtil.success(listData);
    }

    @GetMapping("/machTypeList")
    public Result machTypeList(@SessionAttribute(SessionAttr.MS_USER) SysUser user,
                               @RequestAttribute(RequestAttr.DEPT_ID) Integer deptId) {
        logger.info("获取设备类型列表,loginer:{},deptId:{}", user.getUsername(), deptId);
        ListData<AppMachTypeDTO> listData = msMachOptionService.machTypeList(deptId);
        return ResultUtil.success(listData);
    }
}
